//package com.sailfish.springbootdemo.configs;
//
//import org.apache.ibatis.session.SqlSessionFactory;
//import org.mybatis.spring.SqlSessionFactoryBean;
//import org.mybatis.spring.SqlSessionTemplate;
//import org.mybatis.spring.annotation.MapperScan;
//import org.springframework.beans.factory.annotation.Qualifier;
//import org.springframework.boot.context.properties.ConfigurationProperties;
//import org.springframework.boot.jdbc.DataSourceBuilder;
//import org.springframework.context.annotation.Bean;
//import org.springframework.context.annotation.Configuration;
//import org.springframework.jdbc.datasource.DataSourceTransactionManager;
//
//import javax.sql.DataSource;
//
///**
// * 数据源 2 配置，假如是sqlserver
// */
//@Configuration(value = "db2")
//@MapperScan(basePackages = "com.sailfish.springbootdemo.dao.db2",sqlSessionFactoryRef = "MssqlSqlSessionFactory2")
//public class MSSQL2Config {
//
//    /**
//     * 配置数据源
//     * @return
//     */
//    @Bean(name = "MssqlDataSource2")
//    @ConfigurationProperties(prefix = "spring.datasource.db2")
//    public DataSource getDateSource() {
//        return DataSourceBuilder.create().build();
//    }
//    /**
//     * 配置事务管理
//     */
//    @Bean(name = "MssqlTransactionManager2")
//    public DataSourceTransactionManager testTransactionManager(@Qualifier("MssqlDataSource2") DataSource dataSource) {
//        return new DataSourceTransactionManager(dataSource);
//    }
//    /**
//     * 配置工厂
//     * @param datasource
//     * @return
//     * @throws Exception
//     */
//    @Bean(name = "MssqlSqlSessionFactory2")
//    public SqlSessionFactory testSqlSessionFactory(@Qualifier("MssqlDataSource2") DataSource datasource)
//            throws Exception {
//        SqlSessionFactoryBean bean = new SqlSessionFactoryBean();
//        bean.setDataSource(datasource);
////        bean.setMapperLocations(new PathMatchingResourcePatternResolver().getResources("classpath*:mapper/mssql2/*.xml"));
//        return bean.getObject();
//    }
//    /**
//     * 配置会话
//     * @param sessionfactory
//     * @return
//     */
//    @Bean("MssqlSqlSessionTemplate2")
//    public SqlSessionTemplate testsqlsessiontemplate(
//            @Qualifier("MssqlSqlSessionFactory2") SqlSessionFactory sessionfactory) {
//        return new SqlSessionTemplate(sessionfactory);
//    }
//}
//
//
